package com.example.recursion;

/**
 * @Description
 * @Date 2021/8/19
 * @Created by Jonathan
 */
public class Hanoi {
    static int count = 0;

    public static void main(String[] args) {
        move(4, 'A', 'B', 'C');
        System.out.println("count:" + count);

    }

    public static void move(int n, char A, char B, char C) {
        if (n == 1) {
            count++;
            System.out.println(n + " " + A + "->" + C);
        } else {
            move(n - 1, A, C, B);
            count++;
            System.out.println(n + " " + A + "->" + C);
            move(n - 1, B, A, C);
        }
    }
}
